package com.axxc.jpa.pattendegign.commons;

import com.axxc.jpa.pattendegign.flyweight.A;

/**
 * @ClassName TestFlyweightPattn
 * @Description //TODO 测试享元模式,如Integer缓存 -128-127.String类
 * @author xxc
 * @data 2018年9月13日下午10:16:52
 * @see {@link http://gitee.com/biuabiu/ }
 * @see java.lang.Integer.valueOf(int)
 */
public class TestFlyweightPattn {

	public static void main(String[] args) {

		C a = new A("a").getA();
		a.show();
		C a2 = new A("b").getA();
		System.out.println(a);
		System.out.println(a == a2);
		System.out.println(a2);

		System.out.println("-------Integer默认缓存-128~127");
		System.out.println(Integer.valueOf(111) == Integer.valueOf(111));
		// -XX:AutoBoxCacheMax=129 指定虚拟机参数,将缓存更多值
		System.out.println(Integer.valueOf(128) == Integer.valueOf(128));
		System.out.println("-------默认开启StringCache");
		String aaa = "aa";
		String aa = "aa";
		System.out.println(aa == aaa);

	}
}
